package com.fu;

import java.sql.*;

/**
 * @author 付大大
 * @description
 * @create 2021-01-30 15:24
 */
public class JdbcDemo01 {
    public static void main(String[] args) throws ClassNotFoundException, SQLException {
        Connection connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/db6", "root", "123456");

        Statement statement = connection.createStatement();

        String sql = "SELECT * FROM user";
        ResultSet resultSet = statement.executeQuery(sql);

        while (resultSet.next()) {
            System.out.println(resultSet.getInt("id") + "\t" + resultSet.getString("name"));
        }
        connection.close();
        statement.close();
        resultSet.close();

    }
}
